package main

import (
	"fmt"
	"runtime"
	"strconv"
	"time"
)

// goroutineTestDemo

//test 编写一个函数每个一秒输出“hello world”
func test() {
	for i := 1; i <= 10; i++ {
		fmt.Println("test()hello world" + strconv.Itoa(i))
		time.Sleep(time.Second)
	}
}

func main() {
	// 查看逻辑cpu运行个数
	num := runtime.NumCPU()
	fmt.Println(num)

	// 开启一个协程
	go test()

	for i := 1; i <= 10; i++ {
		fmt.Println("main()hello golang" + strconv.Itoa(i))
		time.Sleep(time.Second)
	}
}
